﻿using NAudio.CoreAudioApi;
using NAudio.Dsp;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Rectangle = System.Windows.Shapes.Rectangle;

namespace AudioVisualization
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        private bool _recordStatus = false;
        private VisualizationHelper visualizationHelper;

        public MainWindow()
        {
            InitializeComponent();
            visualizationHelper = new VisualizationHelper(WaveForm, new VisualizationHelper.WaveFormArgs()
            {
                RecNum = 25,
                RecMargin = 3,
                RecWidth = 3,
                RecHeight = 50
            });
        }

        private void BeginRecord()
        {
            btn.Content = "停止录制";
            visualizationHelper.BeginRecord();
        }

        private void StopRecord()
        {
            btn.Content = "开始录制";
            visualizationHelper.StopRecord();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            _recordStatus = !_recordStatus;
            if (_recordStatus)
            {
                BeginRecord();
            }
            else
            {
                StopRecord();
            }
        }

    }
}
